package 笔试.OPPO;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class 三元组个数 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] nums = new int[n];
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            nums[i] = in.nextInt();
            map.put(nums[i], map.getOrDefault(nums[i], 0) + 1);
        }
        ArrayList<Integer> list = new ArrayList<>(map.values());
        ArrayList<Integer> cur = new ArrayList<>();
        ArrayList<Integer> res = new ArrayList<>();
        res.add(0);
        int index = 0;
        solve(list, cur, index, res);
        System.out.println(res.get(0));
    }

    private static void solve(ArrayList<Integer> list, ArrayList<Integer> cur, int index, ArrayList<Integer> res) {
        if (cur.size() == 3) {
            int temp = 1;
            for (int i = 0; i < cur.size(); i++) {
                temp *= cur.get(i);
            }
            Integer integer = res.get(0);
            integer += temp;
            res.set(0, integer);
            return;
        }
        for (int i = index; cur.size() + list.size() - i + 1 > 3; i++) {
            cur.add(list.get(i));
            solve(list, cur, i + 1, res);
            cur.remove(cur.size() - 1);
        }
    }
}
